new Vue({
  el: '#main',
  data: {
    unfold: false,
    aryType: ['退学', '休学', '毕业', '转专业', '复学'], // 静态数据
    selectedTypeValue: '',
    selectedTypeText: '',
    minDate: '2021-09-01', // 静态数据
    maxDate: '2024-04-01', // 静态数据
    selectedDate: '',
    aryField: ['操作用户', '专修编号', '操作对象'], // 字段名是固定数据
    selectedFieldValue: '0', // 给定值作为默认项
    selectedFieldName: '',
    queryValue: '',
    fuzzy: false,
    students: [
      {
        checked: false,
        logId: 1,
        studentName: '张三',
        student: '123456',
        operatedUser: '学生1',
        updateType: '休学',
        description: '因病暂时休学',
        updateTime: '2021-09-01',
      },
    ],
  },
  methods: {
    reset () {
      this.selectedTypeValue = ''
    },
    toggle () {
      this.unfold = !this.unfold
    },
  },
  watch: {
    selectedTypeValue (newData) {
      this.selectedTypeText = newData === '' ? newData : this.aryType[newData]
    },
    selectedFieldValue: {
      handler (newData) {
        this.selectedFieldName = this.aryField[newData]
      },
      immediate: true,
    },
  },
  computed: {
    unfoldOrfold () {
      return this.unfold ? '收起' : '展开'
    },
    isAll: {
      get () {
        return this.students.every((item) => item.checked)
      },
      set (value) {
        this.students.forEach((item) => (item.checked = value))
      },
    },
  },
})
